﻿
using Models.WebAdmin;
using Newtonsoft.Json;
using UtilsORM.MySqlData;
using ServiceWeb.DBGateway;
using UtilsORM.MySqlData;
////using System.Web.Script.Serialization;

namespace ServiceWeb.WebAdmin
{
    public class ServiceGateWay
    {
        public List<ZtreeItemModel> getZTreeGateWayList(string p_guid)
        {

            ZtreeItemModel ZI = new ZtreeItemModel();
            List<ZtreeItemModel> ZIList = new List<ZtreeItemModel>();

            List<iot_device> devices = new List<iot_device>();
            if (!string.IsNullOrEmpty(p_guid))
            {
                devices = new DBIotDevice().getDeviceGateWayByProductList(p_guid);
            }
            else
            {
                devices = new DBIotDevice().getDeviceGateWayAllList();
            }

            foreach (var device in devices)
            {
                ZI = new ZtreeItemModel();
                ZI.id = device.d_guid;
                ZI.pId = device.d_guid;
                ZI.name = device.d_name;
                ZI.open = "true";
                ZI.isParent = "false";
                ZIList.Add(ZI);
            }

            return ZIList;
        }

    }
}
